/*
 * Copyright (c) 2012, marco.tamburelli@gmail.com
 * All rights reserved.
 * 
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met: 
 * 
 * 1. Redistributions of source code must retain the above copyright notice, this
 *    list of conditions and the following disclaimer. 
 * 2. Redistributions in binary form must reproduce the above copyright notice,
 *    this list of conditions and the following disclaimer in the documentation
 *    and/or other materials provided with the distribution. 
 * 
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 * 
 * The views and conclusions contained in the software and documentation are those
 * of the authors and should not be interpreted as representing official policies, 
 * either expressed or implied, of the CometMI Project.
 */
package org.cometmi.gwt.shared;

import org.cometmi.gwt.shared.exceptions.InvalidArgumentException;
import org.cometmi.gwt.shared.request.var.ReturnVar;

public abstract class MiManager
{
	protected MiQueuePool queues;

	/**
	 * Set the internal {@link MiQueuePool} instance, required by some method.
	 * 
	 * @param queues
	 */
	public void setQueues(MiQueuePool queues)
	{
		this.queues = queues;
	}

	/**
	 * Publishes a constructor call of the object the proxy is designed. The
	 * creation of a {@link MiObject} will be performed to each client.
	 * 
	 * @param objectId The id of the target object.
	 * @param targetType The type of the target object whose constructor
	 *        invocation is requested.
	 * @param argsSignature The signature of constructor arguments.
	 * @param args Requested arguments.
	 * @throws InvalidArgumentException
	 */
	public abstract void publishConstructor(String objectId, Class<? extends MiObject> targetType,
			String argsSignature, Object[] args) throws InvalidArgumentException;

	/**
	 * Publishes a method, in the same was as a constructor; then returns a
	 * proxy to the target method returned object.
	 * 
	 * @param objectId The id of the target object. * @param targetType The type
	 *        of the target object whose constructor invocation is requested.
	 * @param methodName
	 * @param argsSignature The signature of method arguments.
	 * @param args Arguments for the proxy method, enabling the invocation
	 *        request.
	 * @param returnType The return type which can be an user defined proxy
	 *        implementing {@link MiProxy} or a {@link ReturnVar} object.
	 * @return an object implementing the provided interface extending
	 *         {@link MiProxy}.
	 * @throws InvalidArgumentException
	 */
	public abstract MiProxy publishMethod(String objectId, Class<? extends MiObject> targetType, String methodName,
			String argsSignature, Object[] args, Class<? extends MiProxy> returnType) throws InvalidArgumentException;

	/**
	 * Publishes a method with no return type (or void), in the same was as a
	 * constructor.
	 * 
	 * @param objectId The id of the target object.
	 * @param targetType The type of the target object whose constructor
	 *        invocation is requested.
	 * @param methodName The name of the method.
	 * @param argsSignature The signature of the argument types.
	 * @param args Arguments for the proxy method, enabling the invocation
	 *        request.
	 * @throws InvalidArgumentException
	 */
	public abstract void publishMethod(String objectId, Class<? extends MiObject> targetType, String methodName,
			String argsSignature, Object[] args) throws InvalidArgumentException;
}
